export function clearHms (date: Date): Date {
    date.setHours(0);
    date.setMinutes(0);
    date.setSeconds(0);
    date.setMilliseconds(0);
    return date;
}

export function isBetween (range: Date[], date: Date) {
    if (!date) {
        return false;
    }
    const start = clearHms(new Date(range[0]));
    const end = clearHms(new Date(range[1]));
    if (!start) {
        return false;
    }
    if (range.length === 1 && start.getTime() === date.getTime()) {
        return true;
    }
    if (range.length === 2 && start.getTime() <= date.getTime() && end.getTime() >= date.getTime()) {
        return true;
    }
    return false;
}

export function sameDate (date1: Date, date2: Date) {
    return '' + date1.getFullYear() + date1.getMonth() + date1.getDate() === '' + date2.getFullYear() + date2.getMonth() + date2.getDate();
}

export function sameMonth (date1: Date, date2: Date) {
    return '' + date1.getFullYear() + date1.getMonth() === '' + date2.getFullYear() + date2.getMonth()
}